#include<iostream>
#include<map>
using namespace std;
int main()
{
	int i,N;
	char op;
	long long int num;
	string pw;
	map<long long int , string> QQuser;
	map<long long int ,string >::iterator iter;
	cin>>N;
	for(i=0;i<N;i++)
	{
		cin>>op>>num>>pw;
		if(op=='N')
		{
			if(QQuser.empty() )
			{
			QQuser.insert(pair<long long int ,string>(num,pw));
			cout<<"New: OK\n";}
			else{
				iter=QQuser.find(num);
				if(iter==QQuser.end() )
			    {
		              	QQuser.insert(pair<long long int ,string>(num,pw));
		              	cout<<"New: OK\n";}
				else
				cout<<"ERROR: Exist\n";
			    } 
		}
		else
		{
		iter=QQuser.find(num) ;
		if(iter!=QQuser.end())
		{
			if(iter->first==num&&iter->second==pw)
				cout<<"Login: OK\n";
			else
			cout<<"ERROR: Wrong PW\n";
					}			
		else
		cout<<"ERROR: Not Exist\n";
		}
	}
	return 0;
 } 
